package cn.itcast;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Exception2 {
    public static void main(String[] args) {
        //show();
        System.out.println(print());

        String str = "2022-12-30 10:39:aasdf52421349";
        //Date d = (Date) str;

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
            Date dd = sdf.parse(str);
            System.out.printf("%tF %<tT %n",dd);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }


    }

    public static int print() {
        int i = 5;
        try {
            i = 3 / 3;
            System.out.println("try i = " + i);
            int t = 5 / 0;
            return i;
        } catch (Exception e) {
            return i;
        } finally {
            ++i;
            System.out.println("finally :程序结束 i=" + i);
            //return i;
        }

    }

    public static void show() {
        try {
            int i = 3 / 3;
            System.out.println("try i = " + i);
            return;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.out.println("finally :程序结束！");
        }

    }
}
